<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>工作面板</title>
	<meta name="decorator" content="default"/>
	<%@include file="/WEB-INF/views/include/treeview.jsp" %>
	<style type="text/css">
	.ztree {overflow:auto;margin:0;_margin-top:10px;padding:10px 0 0 10px;}
	html,body{height:100%} 
	.scrum-box{
		height:100%;
		padding: 15px 0;
		box-sizing: border-box;
	}
	ul,li{
		list-style: none;
		padding: 0;
		margin: 0;
	}
	.scrum-stage{
		float: left;  
	    width: 31.33333%;
	    height: 100%;	    
	    border-radius: 3px;	    
	    background-color: #EEEEEE;
	    margin:0 1%;
	}
	.scrum-stage ul{
		padding: 0 10px 10px;
	}
	.list-group{
		overflow-y:scroll;
		height: 90%;	
	}
	.list-group li{
		position: relative;
	    display: block;
	    padding: 10px 15px;
	    background-color: white;
        border-radius: 3px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
        cursor: pointer;
        margin-bottom: 10px;
	}
	.task-box a{
		font-size: 16px;
        font-weight: 800;
	}
	.task-box p{
		margin: 0;
		padding:6px 0;
	}
	.taskfoot{
		overflow: hidden;
	}
	.taskfoot span{
		float: left;
		line-height: 30px;
	}
	.taskfoot button{
		float: right;
	}
	.stage-name{
		padding: 10px 18px;
	    font-size: 15px;
	    font-weight: bold;
	}
	</style>
	<script type="text/javascript">
	function taskForm(taskId,taskGroupId){
		var url = "${ctx}/pro/projectTask/form?id="+taskId+"&taskGroup.id="+taskGroupId;
		top.$.jBox.open("iframe:"+url, "任务详情",810,$(top.document).height()-140,{
            buttons:{"提交":"ok", "关闭":true}, bottomText:"任务详情",submit:function(v, h, f){
                var code;
                if (v=="ok"){
                	// 执行保存
                    //loading('正在提交，请稍等...');
                	h.find("iframe")[0].contentWindow.submitForm();
                	location.reload();
                    return false;
                }
            }, loaded:function(h){
                $(".jbox-content", top.document).css("overflow-y","hidden");
            }
        });
	}
	function taskFormDisable(taskId,taskGroupId){
		var url = "${ctx}/pro/projectTask/formDisable?id="+taskId+"&taskGroup.id="+taskGroupId;
		top.$.jBox.open("iframe:"+url, "任务详情",810,$(top.document).height()-120,{
            buttons:{"关闭":true}, bottomText:"任务详情",submit:function(v, h, f){
                var code;
                if (v=="ok"){
                	// 执行保存
                    //loading('正在提交，请稍等...');
                	h.find("iframe")[0].contentWindow.submitForm();
                	location.reload();
                    return false;
                }
            }, loaded:function(h){
                $(".jbox-content", top.document).css("overflow-y","hidden");
            }
        });
	}
	function deleteTask(id){
		confirmx("确定要归档该任务吗？",function(){
			var url = "${ctx}/pro/projectTask/deleteForWorkPanel/?id="+id;
            $.ajax({
                type: 'GET',
                url : url,
                async:false,
                success : function(data) {
                        alertx("归档成功");
                        location.reload();
                        /* window.parent.page();                                     //调用父窗体方法，当关闭子窗体刷新父窗体
                        window.parent.window.jBox.close(); */            //关闭子窗体
                },
                error : function(data){
                	alertx("无权限");
                }
            });
		})
	}
	</script>
</head>
<body>
	<div class="scrum-box">
		<div class="scrum-stage">
			<div class="stage-name">
				待处理  
			</div>
			<ul class="list-group">
				<c:forEach items="${taskList}" var="task">
				<shiro:hasPermission name="pro:projectTask:edit">
					<li>
						<div class="task-box">
							<a href="javascript:void(0);" onclick="taskForm('${task.id}','${task.taskGroup.id}');">${task.name}</a>
							<p>
							  任务优先级:${fns:getDictLabel(task.priority, "task_priority", "1")}	
							</p>						
							<div class="taskfoot">
								截止日期:<fmt:formatDate value="${task.endTime}" pattern="yyyy-MM-dd" />
								<button class="btn btn-success" onclick="deleteTask('${task.id}');">归档</button>
							</div>						
						</div>
						
					</li>
				</shiro:hasPermission>
				<shiro:lacksPermission name="pro:projectTask:edit">
					<li>
						<div class="task-box">
						<a href="javascript:void(0);" onclick="taskFormDisable('${task.id}','${task.taskGroup.id}');">${task.name}</a>
						<p>
						任务优先级:${fns:getDictLabel(task.priority, "task_priority", "1")}
					    </p>
					    <div class="taskfoot">
					    <span>
						截止日期:<fmt:formatDate value="${task.endTime}" pattern="yyyy-MM-dd" />
						</span>
						<button class="btn btn-success" onclick="deleteTask('${task.id}');">归档</button>
						 </div>
					    </div>
					</li>
				</shiro:lacksPermission>
				</c:forEach>
			</ul>
	</div>
		<div class="scrum-stage">
			<div class="stage-name">
				进行中
			</div>
			<ul class="list-group">
				<c:forEach items="${ongoingList}" var="task">
				<shiro:hasPermission name="pro:projectTask:edit">
					<li>
						<div class="task-box">
						<a href="javascript:void(0);" onclick="taskForm('${task.id}','${task.taskGroup.id}');">${task.name}</a>
						<p>
						任务优先级:${fns:getDictLabel(task.priority, "task_priority", "1")}
						
					    </p>
					    <div class="taskfoot">
					    	<span>
					    	截止日期:<fmt:formatDate value="${task.endTime}" pattern="yyyy-MM-dd" />
					    	</span>
						    <button class="btn btn-success" onclick="deleteTask('${task.id}');">归档</button>
						</div>
					</div>
					</li>
				</shiro:hasPermission>
				<shiro:lacksPermission name="pro:projectTask:edit">
					<li>
						<div class="task-box">

						<a href="javascript:void(0);" onclick="taskFormDisable('${task.id}','${task.taskGroup.id}');">${task.name}</a>
						<p>
						任务优先级:${fns:getDictLabel(task.priority, "task_priority", "1")}
					    </p>
					    <div class="taskfoot">
					    	<span>
						截止日期:<fmt:formatDate value="${task.endTime}" pattern="yyyy-MM-dd" />
					       </span>
						<button class="btn btn-success" onclick="deleteTask('${task.id}');">归档</button>
					</div>
					</div>
					</li>
				</shiro:lacksPermission>
				</c:forEach>
			</ul>
	</div>
		<div class="scrum-stage">
			<div class="stage-name">
				已归档
			</div>
			<ul class="list-group">
				<c:forEach items="${deleteList}" var="task">
					<li>
						<div class="task-box">
						<a href="javascript:void(0);" onclick="taskFormDisable('${task.id}','${task.taskGroup.id}');">${task.name}</a>
						<p>
						任务优先级:${fns:getDictLabel(task.priority, "task_priority", "1")}
					    </p>
					    <div class="taskfoot">
					    	<span>
						截止日期:<fmt:formatDate value="${task.endTime}" pattern="yyyy-MM-dd" />
						    </span>
						</div>		
						</div>					
					</li>
				</c:forEach>
			</ul>
	</div>
	</div>
</body>
</html>